# -*- coding: utf-8 -*-
# @Time    : 2018/4/18 16:14
# @Author  : Soft
# @File    : ZStuExecl.py
# @Software: PyCharm
# #Desc    : 自习记录导出导入
from module.ExeclUtils import *


def getZStuExecl(zs):
    """
    自习记录导出
    :param zs: 自习记录数组
    """
    status = [u'缺勤', u'出勤', u'请假']
    style = [red, white, yellow]
    book = getWriteBook()
    sheet = book.add_sheet("ZX")
    title = [u'序号', u'学生名', u'状态', u'签到时间']
    for i, v in enumerate(title):
        sheet.write(0, i, v)
    for row, z in zip(range(1, len(zs) + 1), zs):
        k = z.get('status')
        sheet.write(row, 0, row)
        sheet.write(row, 1, z.get('stu').get('stu_name'))
        sheet.write(row, 2, status[k], style[k])
        sheet.write(row, 3, z.get('datetime'))
    xls_file = saveTempFile(book, "zx.xls")
    return xls_file
